/*
 * GetSolution.java
 *
 * Created on 18 de febrero de 2007, 05:35 PM
 */

package networkFlow;

/**
 *
 * @author tavobula
 */
public class GetSolution {
    
    /** Creates a new instance of GetSolution */
    public GetSolution() {
    }
    
    public static int[][] solve(int[][] e, int nodes){
        
        int[][] sol=new int[nodes+1][nodes+1];
        
        Edge[] edges=new Edge[e.length];
        
        for(int i=0;i<e.length;++i)edges[i]=new Edge(e[i][0],e[i][1],e[i][2],e[i][3],e[i][4]);
        
        Network n=new Network(nodes+1);
        for(int i=0; i<edges.length;++i){
            n.insert(edges[i]);
        }
        
        NetworkMinCost nmc=new NetworkMinCost(n,0,nodes);
        
        // System.out.println(NetworkUtilities.cost(n));
        
        for(int i=0; i<n.getV();++i){
            AdjList A = n.getAdjList(i);
            for(Edge ed=A.beg();!A.end(); ed=A.nxt()){
                int origin=ed.getV();
                int dest=ed.getW();
                int flow=ed.getPflow();
                sol[origin][dest]=flow;
            }
            
        }
        return sol;
    }
    
}
